<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>随机色图</title>
    <script src="https://cdn.static.runoob.com/libs/jquery/1.8.3/jquery.js"></script>    
</head>
<body>
<div id="result"></div>
<script>
$.getJSON("https://api.lolicon.app/setu/?r18=2", function(resp) {
	console.log(resp)
    let quota=resp["quota"];
	if(quota){
		let data=resp["data"][0];
		$('#result').html(`
			<p>剩余额度：${quota}</p>
			<p>作者：${data["author"]}</p>
			<p>pid：${data["pid"]}</p>
			<p>标题：${data["title"]}</p>
			<p>大小：${data["height"]}*${data["width"]}</p>
			<p>标签：${data["tags"]}</p>
			<img src="${data["url"]}"/>
		`);
	}
	else{
		let date=new Date(0,0,0,0,0,resp["quota_min_ttl"]);
		$('#result').html(`
			<p>今日额度已用完，距离下一次调用额度恢复还剩${date.getHours()}时${date.getMinutes()}分${date.getSeconds()}秒（总${resp["quota_min_ttl"]}秒）</p>
		`);
	}
});
</script>
</body>
</html>
